<?php
function urlTranslate($url)
{
	$ua=$_SERVER['HTTP_USER_AGENT'];
	if (substr($url,0,3)=='smb')
	{
		$components=explode('/',$url,4);
		$windows='\\\\'.$components[2].'\\'.str_replace("/","\\",$components[3]);
		if (strpos($ua, 'MSIE'))
			return linkTranslateIE($windows);
		if (strpos($ua, 'Konqueror'))
			return linkTranslateURL($url);
		return htmlspecialchars($windows);
	}
	return linkTranslateURL($url);
}

function linkTranslateIE($url)
{
	$pos=strrpos($url,'\\')+1;
	$url1=substr($url,0,$pos);
	$url2=substr($url,$pos);

	$urllink1=htmlspecialchars('file://'.$url1);
	$urllink2=htmlspecialchars($url2);
	$url1=htmlspecialchars($url1);

	return "<a href=\"$urllink1\">$url1</a> <a href=\"$urllink1$urllink2\">$url2</a>";
}

function linkTranslateURL($url)
{

	$pos=strrpos($url,'/')+1;
	$urllink1=substr($url,0,$pos);
	$urllink2=substr($url,$pos);

	return "<a href=\"$urllink1\">$urllink1</a> <a href=\"$urllink1$urllink2\">$urllink2</a>";
}

?>
